package com.freesky.biz.abchina.controller;

import com.freesky.biz.abchina.api.AbChinaCoupon;
import com.freesky.biz.abchina.domain.TMaotaiCountRecord;
import com.freesky.biz.abchina.domain.TMaotaiRecord;
import com.freesky.biz.abchina.domain.TMaotaiShare;
import com.freesky.biz.abchina.domain.TPrivateUser;
import com.freesky.biz.abchina.service.IMaotaiRecordService;
import com.freesky.biz.abchina.service.IPrivateUserService;
import com.freesky.common.annotation.Log;
import com.freesky.common.core.controller.BaseController;
import com.freesky.common.core.domain.AjaxResult;
import com.freesky.common.core.page.TableDataInfo;
import com.freesky.common.enums.BusinessType;
import com.freesky.common.exception.CustomException;
import com.freesky.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/abchina/maotai/")
public class MaotaiRecordController extends BaseController {

    @Autowired
    private IMaotaiRecordService maotaiRecordService;

    /**
     * 抢茅台列表
     */
    @PreAuthorize("@ss.hasPermi('abchina:maotai:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMaotaiRecord maotaiRecord) {
        startPage();
        List<TMaotaiRecord> list = maotaiRecordService.findList(maotaiRecord);
        return getDataTable(list);
    }

    @Log(title = "抢茅台", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:maotai:export')")
    @GetMapping("/export")
    public AjaxResult export(TMaotaiRecord maotaiRecord,
                             HttpServletResponse response) {
        return maotaiRecordService.exportFile(maotaiRecord);
    }

    /**
     * 抢茅台列表
     */
    @PreAuthorize("@ss.hasPermi('abchina:maotai:shareList')")
    @GetMapping("/listShare")
    public TableDataInfo listShare(TMaotaiShare maotaiShare) {
        startPage();
        List<TMaotaiShare> list = maotaiRecordService.findShareList(maotaiShare);
        return getDataTable(list);
    }

    @Log(title = "抢茅台", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:maotai:exportShare')")
    @GetMapping("/exportShare")
    public AjaxResult exportShare(TMaotaiShare maotaiShare,
                             HttpServletResponse response) {
        return maotaiRecordService.exportShareFile(maotaiShare);
    }

    /**
     * 抢茅台统计
     */
    @PreAuthorize("@ss.hasPermi('abchina:maotai:maotaiCountList')")
    @GetMapping("/listMaotaiCount")
    public TableDataInfo listMaotaiCount(TMaotaiCountRecord entity) {
        startPage();
        List<TMaotaiCountRecord> list = maotaiRecordService.findMaotaiCountList(entity);
        return getDataTable(list);
    }

    @Log(title = "抢茅台", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('abchina:maotai:exportMaotaiCount')")
    @GetMapping("/exportMaotaiCount")
    public AjaxResult exportMaotaiCount(TMaotaiCountRecord entity,
                                  HttpServletResponse response) {
        return maotaiRecordService.exportMaotaiCount(entity);
    }

}
